from app_obj import *
import re

def work_add(share_text,looks = 500,using_lock = False):
	"""[向数据库里添加任务]

	Args:
		share_text = '78 Angela🍃发布了一篇小红书笔记，快来看吧！😆 2vZHR3Uj0jwLyYj 😆 http://xhslink.com/r5MgXc，复制本条信息，打开【小红书】App查看精彩内容！',
		xhs_id = "124235"
  		looks = 1000
		using_lock = bool
	"""
	# user_name = re.findall('\s(.+)发布了一篇小红书笔记，快来看吧！',share_text)[0] # 解析用户名
	# text_code = re.findall('😆 (.+) 😆',share_text)[0] # 解析分享口令，备用
	share_link = re.findall('http://xhslink.com/\w{5,7}',share_text)[0] # 解析链接，用于selenium后续提取需要的文章

	kwargs  = {
	# "share_text" : share_text,
	"looks" : looks,
	"using_lock" : using_lock,
	# 'user_name':user_name,
	# 'text_code':text_code,
	'share_link':share_link
	}
 
	logger.info(kwargs)

	xhs_tab_share.insert_one(kwargs) # 上传任务至数据库

def reset_lock(): # 将所有lock为true的数据更新为false
	pass


def main():

	work_add(share_text = '20 Angela🍃发布了一篇小红书笔记，快来看吧！ 😆 psDoLIqCZDUuWJV 😆 http://xhslink.com/PE0Bce，复制本条信息，打开【小红书】App查看精彩内容！',
	looks = 5000)



if __name__ == '__main__':
    main()